package com.example.mybatis.mapper;

import com.example.mybatis.model.UserInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;


@Mapper
@Component
public interface UserInfoMapper {


    @Select("select * from userinfo")
    List<UserInfo> getUserInfoAll();

    @Select("select * from userinfo where delete_flag = #{flag} and gender = #{gender}")
    List<UserInfo> getUserInfoByDeleteFlag(@Param("flag") Integer deleteFlag, Integer gender);

    @Insert("insert into userinfo (username , password , age , gender) value (#{username},#{password} , #{age} , #{gender})")
    Integer insert(UserInfo userInfo);

    @Delete("delete from userinfo where id = #{id}")
    Integer delete(Integer id);

    @Insert("insert into userinfo (username , password , age , gender) " +
            "value (#{userinfo.username},#{userinfo.password} , #{userinfo.age} , #{userinfo.gender})")
    Integer insert2(@Param("userInfo") UserInfo userInfo);

    @Update("update userinfo set password = #{password} , age = #{age} , gender = #{gender} where id = #{id}")
    Integer update(UserInfo userInfo);

    @Select("select * from userinfo where username like '%${username}%'")
    List<UserInfo> queryUserInfoByLike(String username);

    @Select("select * from userinfo where username like CONCAT('%', #{username}, '%')")
    List<UserInfo> queryUserInfoByLike2(String username);
}
